/**
 * @作者 Lucas
 * @创建时间 2020/4/24 15:14
 */
package com.lucas.springboot_restful_api.core.configuration;

import com.lucas.springboot_restful_api.core.interceptors.PermissionInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class InterceptorConfiguration implements WebMvcConfigurer {

    @Value("${lucas.security.enable:false}")
    private Boolean enablePermissionInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        if (enablePermissionInterceptor) {
            registry.addInterceptor(new PermissionInterceptor());
        }
    }
}
